package com.faithbj.process;

import com.faithbj.common.model.CheckTotal;

import java.util.Collections;
import java.util.List;

/**
 * User: xiongyuanwei
 * Date: 12-7-19
 * Time: 下午5:42
 */
public class StreetRegionIdsCondition implements GroupableCondition<CheckTotal> {

    private List<String> streets = Collections.emptyList();

    StreetRegionIdsCondition(List<String> streets) {
        this.streets = streets;
    }

    @Override
    public boolean isSatisfiedBy(CheckTotal checkTotal) {
        String regionId = checkTotal.getRegionId();
        return regionId != null && streets.contains(regionId);
    }

    @Override
    public boolean isEmpty() {
        return false;
    }

    @Override
    public Object getGroupKey(CheckTotal checkTotal) {
        return checkTotal.getRegionId();
    }

    @Override
    public boolean isGroupKeySatisfied(CheckTotal checkTotal) {
        return isSatisfiedBy(checkTotal);
    }
}
